package com.fenghuajueli.module_user.adapter;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.RelativeLayout;

import androidx.recyclerview.widget.RecyclerView;

import com.fenghuajueli.libbasecoreui.user.UserInfoUtils;
import com.fenghuajueli.module_user.R;
import com.youth.banner.adapter.BannerAdapter;

import java.util.List;

/**
 * ===========================================================
 * author：songpeng on 12/17/20 09:43
 * email：fenghuajueli@gmail.com
 * ===========================================================
 * vip页banner适配器
 */
public class VipBannerImageAdapter extends BannerAdapter<Integer, VipBannerImageAdapter.BannerViewHolder> {

    public VipBannerImageAdapter(List<Integer> mDatas) {
        super(mDatas);
    }

    @Override
    public BannerViewHolder onCreateHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.vip_banner_item_layout, parent, false);
        return new BannerViewHolder(view);
    }

    @Override
    public void onBindView(BannerViewHolder holder, Integer data, int position, int size) {
        holder.ivBannerImg.setImageResource(data);
        if (position == 0) {
            holder.vipInfoContainer.setVisibility(View.VISIBLE);
        } else {
            holder.vipInfoContainer.setVisibility(View.GONE);
        }
        if (UserInfoUtils.getInstance().isVip()) {
            holder.ivVipStatusIcon.setImageResource(R.mipmap.huiyuanweikaitong_02);
        } else {
            holder.ivVipStatusIcon.setImageResource(R.mipmap.huiyuanweikaitong_01);
        }

    }



    static class BannerViewHolder extends RecyclerView.ViewHolder {

        ImageView ivBannerImg;
        RelativeLayout vipInfoContainer;
        ImageView ivVipStatusIcon;

        public BannerViewHolder(View view) {
            super(view);
            this.ivBannerImg = view.findViewById(R.id.ivBannerImg);
            this.vipInfoContainer = view.findViewById(R.id.vipInfoContainer);
            this.ivVipStatusIcon = view.findViewById(R.id.ivVipStatusIcon);
        }

    }
}